Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fdir

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fdir

The fastest directory crawler & globbing alternative to glob, fast-glob, & tiny-glob. Crawls 1m files in < 1s

  • 6.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7M
decreased by-17.56%
Maintainers
1
Weekly downloads
 
Created

What is fdir?

The fdir npm package is a fast and efficient directory crawler that allows you to read and list files in a directory tree. It is designed to be highly performant and can handle large directories with ease.

What are fdir's main functionalities?

Basic Directory Crawling

This feature allows you to crawl a directory and get a list of all files with their full paths. The code sample demonstrates how to use fdir to crawl a directory and log the list of files.

const { fdir } = require('fdir');
const api = new fdir().withFullPaths().crawl('path/to/directory');
api.withPromise().then(files => console.log(files));

Filtering Files

This feature allows you to filter the files based on a condition. The code sample shows how to filter files to include only JavaScript files.

const { fdir } = require('fdir');
const api = new fdir().withFullPaths().filter(path => path.endsWith('.js')).crawl('path/to/directory');
api.withPromise().then(files => console.log(files));

Using Streams

This feature allows you to use streams to handle the files as they are found. The code sample demonstrates how to use a stream to log each file as it is crawled.

const { fdir } = require('fdir');
const api = new fdir().withFullPaths().crawl('path/to/directory');
api.withStream().on('data', file => console.log(file));

Using Async/Await

This feature allows you to use async/await syntax for better readability and control over asynchronous operations. The code sample shows how to use async/await to crawl a directory and log the list of files.

const { fdir } = require('fdir');
(async () => {
  const api = new fdir().withFullPaths().crawl('path/to/directory');
  const files = await api.withPromise();
  console.log(files);
})();

Other packages similar to fdir

Keywords

FAQs

Package last updated on 16 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc